package xFGE.xDisplay.xScene
{
	import flash.display.DisplayObject;
	
	import xFGE.Interface.ISceneObject;
	import xFGE.xDisplay.UIComponentAssistBase;
	/**
	 * 场景对象
	 * @author Ben
	 * @version 1.0
	 * @updated 26-三月-2009 15:55:18
	 */
	public class xSceneObj extends UIComponentAssistBase
	{	
		private var _isInit:Boolean= false;
		
		
		public function xSceneObj(name:String,x:int,y:int) 
		{
			//TODO: implement function
			super();
			this.name = name;
			this.x = x;
			this.y = y;
			//this.width = w;
			//this.height = h;
			
			//默认创建1个空白层
			CreateLayer("blank",0,0);
		}
		/**
		 * 创建层
		 *  
		 * @param name
		 * @param x
		 * @param y
		 * @param w
		 * @param h
		 * 
		 */
		public function CreateLayer(name:String,x:int,y:int):xLayerObj
		{
			var layer:xLayerObj = new xLayerObj(name,x,y)
			addChild(layer);
			return layer;
		}
		
		/**
		 * 获取层 
		 * @param name
		 * @return 
		 * 
		 */
		public function GetLayerByName(name:String):xLayerObj
		{
			return getChildByName(name) as xLayerObj;
		}
		
		/**
		 * 初始化接口
		 * @return 
		 * 
		 */
		public function InitScene():Boolean
		{
			_isInit = true;
			return true;
		}
		
		/**
		 * 进入场景接口
		 * 
		 */
		public function EnterScene():void
		{
			if(!_isInit)InitScene();
		}
		
		/**
		 * 移出场景接口
		 * 
		 */
		public function OutScene():void
		{
			
		}
		/**
		 * 接收网络信息 
		 * @param msg
		 * 
		 */
		public function onReceive(msg:XML):void{
			
		}
		/**
		 * 重写addchild，只能接受layer添加 
		 * @param child
		 * @return 
		 * 
		 */
		override public function addChild(child:DisplayObject):DisplayObject
		{
			if(child is xLayerObj)return super.addChild(child);
			return null;
		}
		
		
	}
}